package com.petRescueCenter.demo.posting.entity.dto;

import java.util.Date;

import com.petRescueCenter.demo.posting.entity.Reply;

import io.swagger.annotations.ApiModelProperty;

public class ReplyDTO {
	@ApiModelProperty(name = "id", value = "评论id", required = false)
	private Long id;
	@ApiModelProperty(name = "userName", value = "评论者姓名", required = false)
	private String userName;
	@ApiModelProperty(name = "userId", value = "评论者id", required = false)
	private Long userId;
	@ApiModelProperty(name = "content", value = "评论内容", required = false)
	private String content;
	@ApiModelProperty(name = "createTime", value = "评论时间", required = false)
	private Date createTime;
	@ApiModelProperty(name = "parentReplyId", value = "被评论的评论id", required = false)
	private Long parentReplyId;
	@ApiModelProperty(name = "parentReplyUserName", value = "被评论者名字", required = false)
	private String parentReplyUserName;
	@ApiModelProperty(name = "postingId", value = "被评论的帖子id", required = false)
	private Long postingId;
	@ApiModelProperty(name = "hasChlidReply", value = "duan", required = false)
	private String parentReplyContent;
	// 被评论的评论别人的
	private String parentReplyParentName;
	private String img;

	public Long getId() {
		return id;
	}

	public String getParentReplyParentName() {
		return parentReplyParentName;
	}

	public void setParentReplyParentName(String parentReplyParentName) {
		this.parentReplyParentName = parentReplyParentName;
	}

	public String getParentReplyContent() {
		return parentReplyContent;
	}

	public void setParentReplyContent(String parentReplyContent) {
		this.parentReplyContent = parentReplyContent;
	}

	public String getUserName() {
		return userName;
	}

	public Long getUserId() {
		return userId;
	}

	public String getContent() {
		return content;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public Long getParentReplyId() {
		return parentReplyId;
	}

	public String getParentReplyUserName() {
		return parentReplyUserName;
	}

	public Long getPostingId() {
		return postingId;
	}

	public void setPostingId(Long postingId) {
		this.postingId = postingId;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public void setParentReplyId(Long parentReplyId) {
		this.parentReplyId = parentReplyId;
	}

	public void setParentReplyUserName(String parentReplyUserName) {
		this.parentReplyUserName = parentReplyUserName;
	}

	public String getImg() {
		return img;
	}

	public void setImg(String img) {
		this.img = img;
	}

	public static ReplyDTO entityToDto(ReplyDTO dto, Reply entity) {
		dto.setContent(entity.getContent());
		dto.setCreateTime(entity.getCreateTime());
		dto.setId(entity.getId());
		if (entity.getParentReply() != null) {
			dto.setParentReplyId(entity.getParentReply().getId());
			dto.setParentReplyUserName(entity.getParentReply().getUser().getName());
			dto.setParentReplyContent(entity.getParentReply().getContent());
			if (entity.getParentReply().getParentReply() != null) {
				dto.setParentReplyParentName(entity.getParentReply().getParentReply().getUser().getName());
			}
		}
		dto.setUserId(entity.getUser().getId());
		dto.setUserName(entity.getUser().getName());
		dto.setCreateTime(entity.getCreateTime());
		dto.setPostingId(entity.getPostingId());
		dto.setImg(entity.getUser().getImg());
		System.err.println(dto.getImg());
		return dto;

	}

	public static Reply dtoToEntity(ReplyDTO dto, Reply entity) {
		entity.setContent(dto.getContent());
		entity.setCreateTime(dto.getCreateTime());
		entity.setId(dto.getId());
		entity.setPostingId(dto.getPostingId());
		return entity;

	}

}
